<?php

class PublicModel extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    /**
     * 新增或修改公众号
     * @param type $data
     */
    public function initPublic($data) {
        $query = $this->db->get_where('wechat_public', array('uid' => $data['uid']));
        $row = $query->num_rows();
        if ($row == 0) {
            // 新增
            $data['cTime'] = time(); //创建时间
            $this->db->insert('wechat_public', $data);
        } else {
            // 修改
            $this->db->update('wechat_public', $data);
        }
    }

    /**
     * 根据管理员ID查询
     * 公众号详情
     * @param type $uid
     * @return Array
     */
    public function getPublicInfo($uid) {
        $query = $this->db->get_where('wechat_public', array('uid' => $uid));
        return $query->row_array();
    }

}
